import java.math.BigDecimal;
import java.util.Scanner;
public class Test {
    public static void main(String[] args) {
        while(true){
        System.out.println("please enter your first number");
        Scanner scan = new Scanner(System.in);
        calculation calculation = new calculation();
        int x =0;
        int y =0;
        if (scan.hasNextInt()) {
             x = scan.nextInt();
            System.out.println("please enter your second number");
            y = scan.nextInt();
//        “使用scanner类获取x，y的值并且传给参数x，y”
        System.out.println("please choose your calculation");
            Scanner scanner1 = new Scanner(System.in);
        if (scanner1.hasNextLine()){
            String method = scanner1.nextLine();
            if (method.equals("add")){
                int result = calculation.add(x, y);
                System.out.println(result);
            }
            if (method.equals("subtract")) {
                int result = calculation.subtract(x, y);
                System.out.println(result);
            }
            if (method.equals("multiply")){

                int result = calculation.multiply(x, y);
                System.out.println(result);
            }
            if (method.equals("divide")){
                if (y == 0){
                    System.out.println("0不能当除数");
                }
                else{double result =calculation.divide(x, y);
                    System.out.println(result);}
            }
            if (method.equals("involution")){
                double result =calculation.involution(x, y);
                System.out.println(result);
            }
            System.out.println("还要继续计算吗？请回答yes或no");
            Scanner scanner2 = new Scanner(System.in);
            if (scanner2.hasNextLine()){
                String answer = scanner2.nextLine();
                if (answer.equals("yes")){continue;}
                if (answer.equals("no")){break;}
                }}}}}}
